import HTTP from '@/libs/http'

class GeneralApi {
  constructor() {
    this.Region = new Region() //
    this.ImgUpload = new ImgUpload()
    this.Queue = new Queue()
  }
}

class Region extends HTTP {
  /**
   * @description: 行政机构相关的操作
   */

  /**
   * @description: 行政机构目录树
   * @author lsr
   * @date 2021.03.06
   * @param {String} regionCode 行政机构编码
   */
  getTree({ regionCode }) {
    return this.request({
      method: 'Get',
      url: '/smart/smart-app/region/tree',
      params: {
        regionCode
      }
    })
  }

  /**
   * @description: 市局、分县局、派出所、责任区
   * @author lsr
   * @date 2020/11/11
   */
  getCitytodis() {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/region/citytodis'
    })
  }

  /**
   * @description: 根据社区获取小区
   * @author lsr
   * @date 2021.03.06
   * @param {String} regionCode 行政区划编码
   */
  getPlace({ regionCode }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/region/place',
      params: {
        regionCode
      }
    })
  }

  /**
   * @description: 根据场所获取楼栋
   * @author: lsr
   * @date: 2021.03.06
   * @param {String} placeCode  场所编码
   */
  getBuild({ placeCode }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/region/building',
      params: {
        placeCode
      }
    })
  }

  /**
   * @description: 根据楼栋获取单元
   * @author: lsr
   * @date: 2021.03.06
   * @param {String} buildCode  行政区域编码
   */
  getUnit({ buildCode }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/region/unit',
      params: {
        buildCode
      }
    })
  }

  /**
   * @description: 根据楼栋编码获取所属楼层
   * @author: lsr
   * @date: 2021.03.06
   *  @param {String} buildCode  行政区域编码
   *  @param {String} unit  行政区域编码
   */
  getFloor({ buildCode, unit }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/region/floor',
      params: {
        buildCode,
        unit
      }
    })
  }

  /**
   * @description: 根据楼栋、单元、楼层获取房屋
   * @author: lsr
   * @date: 2021.03.06
   *  @param {String} buildCode  行政区域编码
   *  @param {String} unit  行政区域编码
   *  @param {String} floor  行政区域编码
   */
  getHouse({ buildCode, unit, floor }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/region/house',
      params: {
        buildCode,
        unit,
        floor
      }
    })
  }

  /**
   * @description: 标签查询
   * @author: lsr
   * @date: 2021.04.28
   *  @param {String} labelType 标签类型
   */
  getLabel({ labelType }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/region/label',
      params: {
        labelType
      }
    })
  }

  /**
   * @description: 根据域名获取行政区划编码
   * @author: lsr
   * @date: 2021.05.31
   *  @param {String} ip ip+端口
   */
  getRegionCode({ ip }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/config/region',
      params: {
        ip
      }
    })
  }

  /**
   * @description: 根据网格code获取网格经纬度范围
   * @author: cx
   * @date: 2021.10.28
   * @param {String} code 网格编码
   */
  getGridScopes({ code }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/region/gridScopes',
      params: {
        code
      }
    })
  }
}

class ImgUpload extends HTTP {
  /**
   * @description: 照片上传
   */

  /**
   * @description: 照片上传
   * @author
   * @date 2020.05.07
   * @param {String} folder 文件夹路径
   * @param {String} file 文件
   */
  upload(data) {
    return this.request({
      method: 'POST',
      url: '/smart/smart-app/file/upload',
      data
    })
  }
}

class Queue extends HTTP {
  /**
   * @description: 查询相关
   */

  /**
   * @description: 行政机构、场所扩展信息
   * @param {String} regionCode 行政机构编码
   */
  getExtend({ regionCode }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/queue/extend',
      params: {
        regionCode
      }
    })
  }
}

const General = new GeneralApi()

export default General
